//
//  CCFirstPageTableViewCell.m
//  CwinCar
//
//  Created by dlios on 15/10/15.
//  Copyright © 2015年 dlios. All rights reserved.
//

#import "CCFirstPageTableViewCell.h"
#import "BaseHeader.h"
@implementation CCFirstPageTableViewCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.leftImg = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, mainScreen_Width / 2.884, mainScree_Height / 7.411)];
        self.leftImg.layer.masksToBounds = YES;
        self.leftImg.layer.cornerRadius = 8. * suitableScreen_Width;
        [self.contentView addSubview:self.leftImg];
        
        self.talking = [[UIImageView alloc]initWithFrame: CGRectMake(mainScreen_Width / 1.595, mainScree_Height / 8.134, mainScreen_Width / 22.058, mainScree_Height / 39.235)];
        [self.talking setImage:[UIImage imageNamed:[NSString stringWithFormat:@"iconfont-iconfontpinglun.png"]]];
        [self.contentView addSubview:self.talking];
        
        self.newsTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(mainScreen_Width / 2.678, 5, mainScreen_Width / 1.704, mainScree_Height / 16.675)];
        self.newsTitleLabel.textColor = [UIColor blackColor];
                self.newsTitleLabel.font = [UIFont systemFontOfSize:16.];
        [self.newsTitleLabel setNumberOfLines:0];
        [self.contentView addSubview:self.newsTitleLabel];
        
        self.commentCountLabel = [[UILabel alloc]initWithFrame:CGRectMake(mainScreen_Width / 1.470, mainScree_Height / 8.893, mainScreen_Width / 9.375, mainScree_Height / 22.233)];
        self.commentCountLabel.textColor = [UIColor grayColor];
                self.commentCountLabel.font = [UIFont systemFontOfSize:13.];
        [self.contentView addSubview:self.commentCountLabel];
        
        self.timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(mainScreen_Width / 2.678, mainScree_Height / 8.893, mainScreen_Width / 4.166, mainScree_Height / 22.233)];
        self.timeLabel.textColor = [UIColor grayColor];
                self.timeLabel.font = [UIFont systemFontOfSize:13.];
        [self.contentView addSubview:self.timeLabel];
        
        self.newsCategoryLabel = [[UILabel alloc]initWithFrame:CGRectMake(mainScreen_Width / 1.25, mainScree_Height / 8.893, mainScreen_Width / 5.357, mainScree_Height / 22.233)];
        self.newsCategoryLabel.textColor = [UIColor grayColor];
                self.newsCategoryLabel.font = [UIFont systemFontOfSize:13.];
        [self.contentView addSubview:self.newsCategoryLabel];
        
        if (mainScree_Height == 736)
        {
            self.newsTitleLabel.font = [UIFont systemFontOfSize:16];
            self.commentCountLabel.font = [UIFont systemFontOfSize:15];
            self.timeLabel.font = [UIFont systemFontOfSize:14];
            self.newsCategoryLabel.font = [UIFont systemFontOfSize:14];
        } else if (mainScree_Height == 667)
        {
            self.newsTitleLabel.font = [UIFont systemFontOfSize:16];
            self.commentCountLabel.font = [UIFont systemFontOfSize:14];
            self.timeLabel.font = [UIFont systemFontOfSize:14];
            self.newsCategoryLabel.font = [UIFont systemFontOfSize:14];
        } else if (mainScree_Height == 568)
        {
            self.newsTitleLabel.font = [UIFont systemFontOfSize:13];
            self.commentCountLabel.font = [UIFont systemFontOfSize:12];
            self.timeLabel.font = [UIFont systemFontOfSize:12];
            self.newsCategoryLabel.font = [UIFont systemFontOfSize:12];
        } else if (mainScree_Height == 480)
        {
            self.newsTitleLabel.font = [UIFont systemFontOfSize:12];
            self.commentCountLabel.font = [UIFont systemFontOfSize:11];
            self.timeLabel.font = [UIFont systemFontOfSize:11];
            self.newsCategoryLabel.font = [UIFont systemFontOfSize:11];
        }
        
    }
    return self;
}
-(void)getCell:(CCFirstPageModel *)model
{
    [self.leftImg sd_setImageWithURL:[NSURL URLWithString:model.newsImage]placeholderImage:[UIImage imageNamed:@"zhanweitu"]];
    
    [self.newsTitleLabel setText: model.newsTitle];
    [self.newsCategoryLabel setText:model.newsCategory];
    
    [self.commentCountLabel setText:[NSString stringWithFormat:@"%@",model.commentCount]];
    
    int temp = model.newsCreateTime.intValue;
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:temp];
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    NSString *tempDate = [formatter stringFromDate:date];
    self.timeLabel.text = tempDate;
    
//    self.timeLabel.text = [NSString stringWithFormat:@"%@", model.newsCreateTime];
}
@end
